Skip to content

Env#13

Merged
steven-passynkov merged 2 commits into
mainfrom
feature/env
Apr 7, 2026
Merged

Env#13
steven-passynkov merged 2 commits into
mainfrom
feature/env

Conversation

@steven-passynkov

@steven-passynkov steven-passynkov commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Environment variable expansion for process commands and working directories via an env parameter (supports $NAME and ${NAME}).
  • Documentation

    • Updated quick-start and process examples to print command stdout and added an interpolation example showing cwd/env usage.
  • Style

    • Exposed CodeLanguage and StreamEventType for type-safe example usage.
  • Tests

    • Added tests for env expansion and import coverage for new public types.
  • Chores

    • Simplified process result shape by removing legacy-result handling.

@coderabbitai

coderabbitai Bot commented Apr 7, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 784c8612-e604-40c3-95a0-ca5cf1b1b8de

📥 Commits

Reviewing files that changed from the base of the PR and between 5fcead4 and e3eecc8.

📒 Files selected for processing (7)
  • README.md
  • leap0/_async/process.py
  • leap0/_schemas/process.py
  • leap0/_sync/process.py
  • leap0/_utils/process.py
  • leap0/models/process.py
  • tests/models/test_process.py
💤 Files with no reviewable changes (2)
  • leap0/_schemas/process.py
  • tests/models/test_process.py
✅ Files skipped from review due to trivial changes (1)
  • README.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • leap0/_sync/process.py
  • leap0/_async/process.py

📝 Walkthrough

Walkthrough

Added environment-variable interpolation for process execution (supports $NAME and ${NAME}), exported CodeLanguage and StreamEventType through the public API, simplified ProcessResult by removing legacy result handling, and updated examples/tests to use the new enums and env expansion behavior.

Changes

Cohort / File(s) Summary
Documentation & Examples
README.md, examples/async_code_interpreter_stream.py, examples/code_interpreter_stream.py
Updated examples to use CodeLanguage.PYTHON; README shows new sandbox.process.execute example demonstrating $NAME/${PLACE} interpolation and cwd/env usage.
Public API Exports
leap0/__init__.py, tests/test_import.py
Added CodeLanguage and StreamEventType to leap0 public exports and tests now assert their presence and expected enum/string values.
Environment Expansion Utils
leap0/_utils/env.py, leap0/_utils/process.py
New expand_env(value, env) and build_command_payload(...) utilities: regex-based placeholder expansion and centralized payload construction that applies env expansion to command and cwd.
Process Clients
leap0/_async/process.py, leap0/_sync/process.py
execute(...) signatures updated to accept `env: dict[str,str]
Process Model & Schema
leap0/models/process.py, leap0/_schemas/process.py
Removed legacy result handling: ProcessResult no longer stores _legacy_result or exposes result; ProcessResult.from_dict reads only stdout/stderr. ProcessResultDict no longer includes optional result key.
Tests: Process Behavior
tests/_async/test_process.py, tests/_sync/test_process.py, tests/models/test_process.py
Added test_execute_expands_env tests for sync/async clients to assert pre-request expansion of command and cwd; removed legacy result handling tests from process model tests.

Sequence Diagram(s)

sequenceDiagram
  participant Client as "ProcessClient"
  participant Utils as "build_command_payload\n(+ expand_env)"
  participant Transport as "HTTP Transport"
  participant Server as "Sandbox API"
  participant Model as "ProcessResult.from_dict"

  Client->>Utils: build payload (command, cwd, timeout, env)
  Utils-->>Client: expanded JSON payload
  Client->>Transport: POST /v1/sandbox/{id}/process/execute (json payload)
  Transport->>Server: HTTP request
  Server-->>Transport: HTTP response (stdout, stderr, exit_code)
  Transport-->>Client: response data
  Client->>Model: ProcessResult.from_dict(response data)
  Model-->>Client: ProcessResult (stdout, stderr, exit_code)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 I hop where placeholders once lay,

$NAME and ${PLACE} now find their way,
Enums declare the language true,
Payloads expand — hooray, woo-hoo! 🥕

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Env' is vague and does not clearly convey the scope or nature of changes; it uses a single word without context about what environment-related functionality is being added or modified. Use a more descriptive title such as 'Add environment variable expansion to process execution' or 'Support env parameter in process.execute()' to clarify the primary change.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/env

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
leap0/_sync/process.py (1)

53-55: Consider extracting shared payload expansion logic.

Sync and async clients now duplicate the same interpolation branch. A shared internal helper would reduce drift risk.

♻️ Possible extraction direction
- payload: JsonObject = {"command": expand_env(command, env) if env else command}
- if cwd is not None:
-     payload["cwd"] = expand_env(cwd, env) if env else cwd
+ payload: JsonObject = build_process_payload(command=command, cwd=cwd, timeout=timeout, env=env)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@leap0/_sync/process.py` around lines 53 - 55, The payload construction in
process.py duplicates expansion logic (using expand_env for command and cwd);
extract that into a shared helper (e.g., a function named build_command_payload
or _expand_payload) that accepts command, cwd, and env and returns the
JsonObject payload with interpolated values, then replace the inline logic in
both the sync and async clients to call this helper (refer to expand_env,
payload creation, command, cwd, env in the diff) to avoid duplication and keep
behavior identical.
README.md (1)

122-126: Show the interpolated result in the example.

The example currently assigns templated but does not show expected output, which makes the interpolation behavior less explicit for readers.

📘 Proposed doc tweak
 templated = sandbox.process.execute(
     command="echo $NAME from ${PLACE}",
     cwd="/workspace/$NAME",
     env={"NAME": "leap0", "PLACE": "sandbox"},
 )
+print(templated.stdout.strip())  # leap0 from sandbox
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@README.md` around lines 122 - 126, The example assigns templated from
sandbox.process.execute but doesn't show the interpolated output; update the
README example around the templated assignment to display the result (e.g., call
or print/return templated or add a comment showing the expected string "leap0
from sandbox") so readers see that sandbox.process.execute performed variable
interpolation on the command "echo $NAME from ${PLACE}" with
env={"NAME":"leap0","PLACE":"sandbox"} and cwd="/workspace/$NAME".
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@leap0/_sync/process.py`:
- Around line 53-55: The payload construction in process.py duplicates expansion
logic (using expand_env for command and cwd); extract that into a shared helper
(e.g., a function named build_command_payload or _expand_payload) that accepts
command, cwd, and env and returns the JsonObject payload with interpolated
values, then replace the inline logic in both the sync and async clients to call
this helper (refer to expand_env, payload creation, command, cwd, env in the
diff) to avoid duplication and keep behavior identical.

In `@README.md`:
- Around line 122-126: The example assigns templated from
sandbox.process.execute but doesn't show the interpolated output; update the
README example around the templated assignment to display the result (e.g., call
or print/return templated or add a comment showing the expected string "leap0
from sandbox") so readers see that sandbox.process.execute performed variable
interpolation on the command "echo $NAME from ${PLACE}" with
env={"NAME":"leap0","PLACE":"sandbox"} and cwd="/workspace/$NAME".

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fc61e528-92c5-4a9a-bfb3-b4b1c7d421d7

📥 Commits

Reviewing files that changed from the base of the PR and between 32c498b and 5fcead4.

📒 Files selected for processing (10)
  • README.md
  • examples/async_code_interpreter_stream.py
  • examples/code_interpreter_stream.py
  • leap0/__init__.py
  • leap0/_async/process.py
  • leap0/_sync/process.py
  • leap0/_utils/env.py
  • tests/_async/test_process.py
  • tests/_sync/test_process.py
  • tests/test_import.py

@steven-passynkov steven-passynkov merged commit 26c2efd into main Apr 7, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant